<template>
	<view class="count">
		<view class="u-font-40 u-p-t-40 u-m-l-40">
			<text>填写发货地址</text>
		</view>
		<view class="u-m-l-40 u-font-35">
			<u-form :model="form" ref="uForm" :label-width="140">
				<u-form-item label="电话" prop="phone">
					<u-input v-model="form.phone" placeholder="手机号码" maxlength="11"/>
					<view slot="right" class="u-m-r-30">
						<u-image width="50rpx" mode="widthFix" src="@/static/image/mai.png" />
					</view>
				</u-form-item>
				<u-form-item label="联系人" prop="name" >
					<u-input v-model="form.name" placeholder="姓名"/>
					<view slot="right" class="u-m-r-30">
						<u-image width="50rpx" mode="widthFix" src="@/static/image/images/order.png" />
					</view>
				</u-form-item>
				<u-form-item label="地址" prop="address">
					<u-input v-model="form.address" placeholder=""/>
					<view slot="right" class="u-m-r-30">
						<u-image width="50rpx" mode="widthFix" src="@/static/image/images/address.png" />
					</view>
				</u-form-item>
				<u-form-item label="门牌号" prop="house_number">
					<u-input v-model="form.house_number" placeholder="例如：11幢1单元8层808室"/>
				</u-form-item>
			</u-form>
		</view>
		<view class="u-p-l-50 u-p-r-50 u-m-60 u-p-t-60">
			<u-button ripple shape="circle" type="primary" @tap="determine">确定</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					phone:'',
					name: '',
					address:'',
					house_number:""
				},
				rules: {
					phone: [{
						required: true,
						message: '请输入手机号',
						trigger: ['blur', 'change']
					}, {
						validator: (rule, value, callback) => {
							return this.$u.test.mobile(value);
						},
						message: '手机号码不正确',
						trigger: ['change', 'blur'],
					}],
					name: [
						{
							required: true,
							message: '请输入姓名',
						// 可以单个或者同时写两个触发验证方式
							trigger: ['blur','change']
						}
					],
					house_number: [
						{
							required: true,
							message: '请输入门牌号',
						// 可以单个或者同时写两个触发验证方式
							trigger: ['blur','change']
						}
					],
				}
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			determine(){
				this.$refs.uForm.validate(valid => {
					if (valid) {
						this.$u.toast('这里验证成功，走接口');
					} else {
						this.$u.toast('验证失败');
					}
				});
			}

		},
	}
</script>

<style>
</style>
